//////////////////////////////////////////////////////////////////////////
#pragma once
#pragma managed
//////////////////////////////////////////////////////////////////////////
using namespace System;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
//////////////////////////////////////////////////////////////////////////
NAMESPACE_BEGIN
//////////////////////////////////////////////////////////////////////////
template<class T, int Length>
[UnsafeValueTypeAttribute]
[StructLayoutAttribute(LayoutKind::Explicit, Size=(Length*sizeof(T)), CharSet=CharSet::Ansi)]
public value class inline_array 
{
private:
	[FieldOffsetAttribute(0)]
	T dummy_item;

public:
	T% operator[](int index) 
	{
		return *((&dummy_item)+index);
	}

	static operator interior_ptr<T>(inline_array<T, Length>% ia) 
	{
		return &ia.dummy_item;
	}
};

template<class T, int dim1, int dim2>
[UnsafeValueTypeAttribute]
[StructLayoutAttribute(LayoutKind::Explicit, Size=(dim1*dim2*sizeof(T)), CharSet=CharSet::Ansi)]
public value class inline_array2d 
{
private:
	[FieldOffsetAttribute(0)]
	T dummy_item;

public:
	T% operator[](int index) 
	{
		return *((&dummy_item)+index);
	}

	static operator interior_ptr<T>(inline_array2d<T, dim1, dim2>% ia) 
	{
		return &ia.dummy_item;
	}
};

template<class T, int dim1, int dim2, int dim3>
[UnsafeValueTypeAttribute]
[StructLayoutAttribute(LayoutKind::Explicit, Size=(dim1*dim2*dim3*sizeof(T)), CharSet=CharSet::Ansi)]
public value class inline_array3d 
{
private:
	[FieldOffsetAttribute(0)]
	T dummy_item;

public:
	T% operator[](int index) 
	{
		return *((&dummy_item)+index);
	}

	static operator interior_ptr<T>(inline_array3d<T, dim1, dim2, dim3>% ia) 
	{
		return &ia.dummy_item;
	}
};

template<class T, int ElementSize, int Length>
[UnsafeValueTypeAttribute]
[StructLayoutAttribute(LayoutKind::Explicit, Size=(Length*ElementSize), CharSet=CharSet::Ansi)]
public value class inline_array_ex 
{
private:
	[FieldOffsetAttribute(0)]
	T dummy_item;

public:
	T% operator[](int index) 
	{
		return *((&dummy_item)+index);
	}

	static operator interior_ptr<T>(inline_array_ex<T, ElementSize, Length>% ia) 
	{
		return &ia.dummy_item;
	}
};

template<class T, int ElementSize, int dim1, int dim2>
[UnsafeValueTypeAttribute]
[StructLayoutAttribute(LayoutKind::Explicit, Size=(dim1*dim2*ElementSize), CharSet=CharSet::Ansi)]
public value class inline_array2d_ex 
{
private:
	[FieldOffsetAttribute(0)]
	T dummy_item;

public:
	T% operator[](int index) 
	{
		return *((&dummy_item)+index);
	}

	static operator interior_ptr<T>(inline_array2d_ex<T, ElementSize, dim1, dim2>% ia) 
	{
		return &ia.dummy_item;
	}
};

//////////////////////////////////////////////////////////////////////////
NAMESPACE_END
//////////////////////////////////////////////////////////////////////////